package com.pattern.strategy.comparable2;

public class Cat implements MyComparable<Cat> {

    int weight, height;

    public Cat(int weight, int height) {
        this.weight = weight;
        this.height = height;
    }

    /**
     * 使用泛型，这里就不用强制类型转换了
     * @param cat
     * @return
     */
    public int compareTo(Cat cat) {
        if (this.weight < cat.weight) return -1;
        else if (this.weight > cat.weight) return 1;
        else return 0;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "weight=" + weight +
                ", height=" + height +
                '}';
    }

}
